package com.feng.seata.web;

import com.feng.common.model.Result;
import com.feng.seata.dto.OrderDto;
import com.feng.seata.service.ProductService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping("/products")
@RestController
public class ProductController {

    @Resource
    private ProductService productService;

    @PutMapping("/minus/stock")
    public Result<?> minusStock(@RequestParam Integer buyNum) {
        productService.minusStock(buyNum);
        return Result.ok();
    }


//    @PostMapping("/deduct4AT")
//    public Boolean deductStock4AT(@RequestBody OrderDto orderInfo) {
//
//    }

//    @PostMapping("/deduct4XA")
//    public Boolean deductStock4XA(@RequestBody OrderDto orderInfo){
//
//    }

    @PostMapping("/deduct4TCC")
    public Result<?> deductStock4TCC(@RequestBody OrderDto orderInfo){
        productService.deductStock(orderInfo);
        return Result.ok();
    }

}
